﻿
namespace IdentityWebApi
{
    public class DemoBgService : BackgroundService
    {
        private readonly ILogger<DemoBgService> _logger;

        public DemoBgService(ILogger<DemoBgService> logger)
        {
            _logger = logger;
        }
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            await Task.Delay(5000);
            var path = Path.Combine(AppContext.BaseDirectory, "test2.txt");
            string s = await File.ReadAllTextAsync(path, stoppingToken);
            await Task.Delay(20000);
            _logger.LogInformation("test.txt内容：{0}", s);
        }
    }
}
